package org.smile.design.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Application {
    public static void main(String[] args) {
//        System.getProperties().put("jdk.proxy.ProxyGenerator.saveGeneratedFiles", "true");
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
        Customer andy = new Customer();
        Customer tom = new Customer();

        Behavior behavior = (Behavior) Proxy.newProxyInstance(andy.getClass().getClassLoader(),
                andy.getClass().getInterfaces(),
                new DeliveryClerk(andy)
//                new InvocationHandler() {
//                    @Override
//                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
//                        System.out.println(this.getClass().getSimpleName() + " take food from store");
//                        Object object = method.invoke(andy, args);
//                        System.out.println(this.getClass().getSimpleName() + " finish job");
//                        return null;
//                    }
//                }
        );

        behavior.obtainFood();

    }
}
